package com.wangfei.swaggerdemo.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.wangfei.swaggerdemo.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

@Tag(name = "用户管理", description = "用户相关接口")
@RestController
@RequestMapping("/manage")
public class UserController {
    @Operation(summary = "用户列表", description = "用户列表接口")
    @GetMapping("/user/lists")
    public String lists(
            @RequestParam(value = "page") @Parameter(description = "当前页") int page,
            @RequestParam(value = "size", defaultValue = "10") @Parameter(description = "页大小") int size
    ) {
        System.out.println(page);
        System.out.println(size);
        return "user lists";
    }

    @Operation(summary = "新增用户", description = "新增接口")
    @PostMapping("/user/add")
    public String add(
            @RequestBody User user
            ) {
        System.out.println(user);
        return "add";
    }

    @Operation(summary = "用户详情")
    @GetMapping("/user/detail")
    public User detail(@RequestParam("id") @Parameter(description = "用户id") Long id) {
        User user = new User();
        user.setSex("男");
        user.setName("小王");
        System.out.println(id);
        return user;
    }
}
